package sql;

import java.sql.ResultSet;
import java.sql.SQLException;

import bean.CustomerBean;

public class CustomerInfoLookUp 
{
	DataAccess dataAccess = new DataAccess();	
	
	public CustomerBean getCustomerInfo(String username, String password) throws ClassNotFoundException, SQLException 
	{
		CustomerBean customer = null;
		String query = "SELECT * " +
				         "FROM CUSTOMER " +
					    "WHERE EMAIL_ADDRESS = '" +username +"' " +
					      "AND CUSTOMER_PASSWORD = '" +password +"'";
		
		ResultSet rset = dataAccess.getSelectResult(query);
		
		while(rset.next())
		{
			customer = new CustomerBean();
			customer.setCustomerId(rset.getInt(1));
			customer.setFirstName(rset.getString(2));
			customer.setLastName(rset.getString(3));
			customer.setScreenName(rset.getString(4));
			customer.setPassword(rset.getString(5));
			customer.setEmailAdd(rset.getString(6));
			customer.setStreet(rset.getString(7)) ;
			customer.setCity(rset.getString(8));
			customer.setState(rset.getString(9));
			customer.setZipCode(rset.getString(10));			
		}
		return customer;		
	}

}
